/* ----------------------------- Noble Steed Engine----------------------------*
Authors : Daniel Randle, Alex Bourne
Date Created : Mar 13 2013

File:
	nsobject.h

Description:
	This file contains the NSObject class which is the base class for all objects in the game
*---------------------------------------------------------------------------*/

#ifndef NSOBJECT_H
#define NSOBJECT_H

/* ---------------------------------Class NSObject-----------------------------*

Description:
	NSObject will provide all the needed virtual functions for other deriving classes to use

*-------------------------------------------------------------------------------*/

// includes
#include <global.h>
#include <string>
#include <nsmath3d.h>
#include <vector>
#include <nsmesh.h>

class NSShader;
class NSCamera;
class NSMapArea;


class NSObject
{
public:
	enum ObjectType {Base, HexTile, DirectionalLight, PointLight, SpotLight};


	NSObject(const std::string & name, const std::string & fileName = "", const std::string & mDirectory = "", const std::string tDirectory = "", bool shadows=false, bool hasTransluscentMaterial=false);
	~NSObject();

	void addInstanceTransform(const NSMatrix4Df & totalTransform);
	void addCopy();

	unsigned int getCopies() const;
	unsigned int getInstanceCount() const;
	unsigned int getID() const;
	const NSMesh * getMesh() const;
	std::string getName() const;
	ObjectType getObjectType() const;

	NSMatrix4Df & instanceTransMat(unsigned int referenceID);
	bool isCastShadows() const;
	bool isHasTransluscentMaterial() const;
	bool isHasMesh() const;

	bool loadMesh(const std::string & fileName="", const std::string & meshDirect="",  const std::string & texDirect="", bool hasTransMat=false);

	bool removeCopy();
	void removeInstanceTransform(unsigned int referenceID);

	void setCastShadows(bool cast);
	void setName(const std::string & name);
	void setVisible(bool set);

	// Static Methods
	static unsigned int getObjectCount();

	// Virtual methods
	virtual void draw();
	virtual void drawSingle(unsigned int refID=0);

protected:
	std::string objectName;
	std::string meshFileName;
	std::string textureDir;
	std::string meshDir;

	std::vector<NSMatrix4Df>* instanceTransforms;

	NSMesh * mesh;

	bool castShadows;

	unsigned int objectID;
	unsigned int copiesInSet;

	ObjectType objType;
	static unsigned int objectCount;
};

#endif